package org.batch.config.batch.validator;

import org.batch.entity.Trading;
import org.cleaver.reflect.FieldUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.item.validator.ValidationException;
import org.springframework.batch.item.validator.Validator;
import org.springframework.stereotype.Component;

/**
 * Trading对象数据校验
 *
 * @author LiKun
 * @date 2021/9/27 17:03
 */
@Component("tradingValidator")
public class TradingValidator implements Validator<Trading> {
    public static final String FIELD_ID = "id";
    private static final Logger logger = LoggerFactory.getLogger(TradingValidator.class);

    public TradingValidator() {
        logger.info("加载数据校验类：TradingValidator");
    }

    @Override
    public void validate(Trading trading) throws ValidationException {
        if (FieldUtil.filedIsNull(trading, FIELD_ID)) {
            logger.info("该对象部分字段为null：{}", trading);
        }
    }
}
